/**
 * 
 */
package org.nyblom.riskcalc.calculate.impl;

import org.nyblom.riskcalc.calculate.ICalculator;

/**
 * @author qw4z1
 *
 */
public class BaseCalculator implements ICalculator {

	private int[] mainForces;
	
	/* (non-Javadoc)
	 * @see org.nyblom.riskcalc.calculate.ICalculator#calculate(int[])
	 */
	public int[] calculate(int[] forces) {
		if(forces[1] > 0 && forces[0] > 0){
			mainForces = forces;
			while(mainForces[0] != 0 && mainForces[1] != 0){
				if(mainForces[0]== 1){
					calculateOne();
				} else if (mainForces[0] == 2){
					calculateTwo();
				} else {
					calculateMany();
				}
			}
		}
		return forces;
	}
	
	private void calculateOne(){
		int[] a = DiceRoller.roll(1);
		int[] d = new int[]{0,0};
		if(mainForces[1] == 1){
			d = DiceRoller.roll(1);
		} else {
			d = DiceRoller.roll(2);
		}
		if(a[0] <= d[0] || a[0] <= d[1]){
			mainForces[0] = mainForces[0] -1;
		}
		
	}
	//TODO finish prioritizing dice
	private void calculateTwo(){
		int[] a = DiceRoller.roll(2);
		int[] d = new int[]{0,0};
		if(mainForces[1] == 1){
			d = DiceRoller.roll(1);
		} else {
			d = DiceRoller.roll(2);
		}
		if(a[0] <= a[1]){
			if(b[0] <= b[1]){
				
			}
		}
	}
	
	private void calculateMany(){
		//TODO do IT!
	}
}
